﻿using System;
using System.Data.OleDb;
using TheOutLetLibrary.Dominio;

namespace TheOutLetLibrary.Infraestrutura {

    class Accessk_phoneDAO: BaseDAO, IGenericDAO<k_phone> {

        public Accessk_phoneDAO(OleDbTransaction transacao)
            : base(transacao) {
        }

        public int Inclua(k_phone entity) {

            OleDbCommand comando = GetCommand();

            comando.CommandText =
                " INSERT INTO k_phone (NR_PEDIDO, ddd, [number]) " +
                " VALUES (@NR_PEDIDO, @ddd, @number)";

            comando.Parameters.Add("@NR_PEDIDO", OleDbType.Integer).Value = entity.NR_PEDIDO;
            comando.Parameters.Add("@ddd", OleDbType.VarChar).Value = entity.ddd;
            comando.Parameters.Add("@number", OleDbType.VarChar).Value = entity.number;
            comando.ExecuteNonQuery();

            comando.CommandText = "SELECT @@IDENTITY";
            entity.COD = Convert.ToInt32(comando.ExecuteScalar());
            return entity.COD;

        }

        public k_phone Ache(int Id) {
            throw new NotImplementedException();
        }
    }
}
